/*
 * FXMain.fx
 *
 * Created on Apr 26, 2009, 5:16:38 PM
 */

package com.dg.gaming.client.fx.gui;

import com.dg.gaming.api.common.AbstractConnectionThread;
import com.dg.gaming.api.common.GameModel;
import com.dg.gaming.api.common.Table;
import com.dg.gaming.client.fx.gui.ConnectionPanel;
import com.dg.gaming.client.fx.gui.IGameController;
import com.dg.gaming.client.fx.gui.TableMessageReciever;
import com.dg.gaming.client.gui.IGameGUI;
import com.dg.gaming.client.IClient;
import com.dg.gaming.client.ITable;
import com.dg.gaming.client.TableConnection;
import nanoxml.XMLElement;
import org.jfxtras.scene.layout.MigLayout;
import org.jfxtras.scene.layout.MigNode;


/**
 * @author dito
 */

public abstract class FXMain extends MigLayout , IClient, ITable,IGameGUI{
    public var table:Table;
    
    public var conn:TableConnection;
    public var gamepanel:GamePanel;
    var cp = ConnectionPanel{mainframe: this}
    var tr:TableMessageReciever;
    init{
        this.fitParent= true;
        this.layout= "fill";
        migContent= MigNode {
              constraints: "center, grow"
              node:cp
           };
    }

    

    public function ku () {
            println("DJKLSJDKSFKS");
        }
    


    
    public override function receiveGameMessage(message:XMLElement) {
        tr.receiveTableMessage(message);

    }
    public  override  function receiveTableMessage(message:XMLElement, tableNum:String) {
        receiveGameMessage(message);


    }
    
    public  override  function connectOK(conn:AbstractConnectionThread){
     
       //delete cp from group.migContent;
       migContent=[];
       this.conn=conn as TableConnection;
       this.conn.setClientInterface(this);
       gamepanel = GamePanel{mainframe: this}
       gamepanel.setUp(this);
       //insert gp into group.migContent;
       migContent=[MigNode {constraints:"center, grow",node:gamepanel}];
       
       tr=new TableMessageReciever(this.conn);

    }
    public abstract function  getGameModel():GameModel;

    public function setupMVC(model:GameModel,
                         controller:IGameController ) {
        tr.setupMVC(model, controller);
    }

}
